feat(sdk): TypeScript SDK — crash-resume via resumeRun - #103
Merged
Conversation
Add Runtime.resumeRun(runId, fn) so a Node/TypeScript agent can re-attach to an existing governed run after a crash. Like the Python SDK's resume_run, it neither creates a new run nor cancels on error: the daemon reloads the run with the budget and usage it had already spent, so enforcement continues without re-spending. Read run.latestCheckpoint() to pick the work back up from the last checkpoint. Test the resume path end-to-end against the in-process mock daemon: a run that crashed after paid steps re-attaches, continues stepping against the same budget (no counter reset), never cancels on a thrown body, and surfaces APIError(404) for an unknown run id. README gets a "Resume after a crash" section.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the resume path to the TypeScript SDK so a Node/TS agent can pick its work
back up after a crash — the JS counterpart to the Python SDK's
resume_run.Runtime.resumeRun(runId, fn)re-attaches to an existing governed run by id. UnlikegovernedRun, it neither creates a new run nor cancels on error: the daemon reloadsnon-terminal runs on restart with the budget and usage they had already spent, so
enforcement continues without re-spending. The agent reads
run.latestCheckpoint()to resume from where it left off — the run id is the only thing it has to keep across
a restart.
Tests
Exercised over real HTTP against the in-process mock daemon (no daemon, no keys):
continues stepping at index 3 (the counter does not reset) — no overspend on restart;
resumeRunnever cancels a run it didn't start when the body throws;APIError(404).Docs: a "Resume after a crash" section in the SDK README and a CHANGELOG entry.
Closes #80.